<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', 'PostsController@index');
Route::get('/test', function(){
//    Cache::put('key', '3232323', 2);

    dd(Cache::get('key', 'default'));
});

Route::resource('discussions','PostsController');
Route::resource('comment','CommentsController');

//用户登录注册 头像更换
Route::get('/user/register','UsersController@register');
Route::get('/user/login','UsersController@login');
Route::get('/user/logout','UsersController@logout');
Route::get('/user/avatar','UsersController@avatar');
Route::post('/user/avatar','UsersController@changeAvatar');
Route::post('/crop/api','UsersController@cropAvatar');
Route::post('/user/register','UsersController@store');
Route::post('/user/login','UsersController@signin');

Route::post('/post/upload','PostsController@upload');

//-------------------------------------------权限控制-------------------------------------------
Route::group(['namespace' => 'Auth'], function()
{
    Route::resource('roles','RolesController');
    Route::resource('permissions','PermissionsController');
});

//-------------------------------------------后台登陆-------------------------------------------
Route::group(['namespace' => 'Auth'], function () {
    Route::get('auth/login', 'AuthController@getLogin');
    Route::post('auth/login', 'AuthController@postLogin');
    Route::get('auth/logout', 'AuthController@getLogout');
});
//-------------------------------------------第三方登陆-------------------------------------------
// 引导用户到新浪微博的登录授权页面
Route::get('auth/weibo', 'Auth\AuthController@weibo');
// 用户授权后新浪微博回调的页面
Route::get('auth/callback', 'Auth\AuthController@callback');

//-------------------------------------------后台--------------------------------------------------
Route::group(['prefix' => 'admin','namespace' => 'Admin', 'middleware' => 'admin.login'], function()
{
    Route::get('/', 'IndexController@index')->name('admin.index.index');
    Route::resource('user', 'UserController');
    Route::resource('menu', 'MenuController');
    Route::resource('role', 'RoleController');
    Route::resource('permission', 'PermissionController');
    Route::resource('tag', 'TagController');
    Route::resource('category', 'CategoryController');
});